package org.jeecg.modules.rental.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.jeecg.modules.rental.entity.RentalSocket;
import org.jeecg.modules.rental.mapper.RentalSocketMapper;
import org.jeecg.modules.rental.service.IRentalSocketService;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Service;

/**
 * @Description: 插座设备
 * @Author: jeecg-boot
 * @Date:   2024-06-25
 * @Version: V1.0
 */
@Service
@RequiredArgsConstructor
public class RentalSocketServiceImpl extends ServiceImpl<RentalSocketMapper, RentalSocket> implements IRentalSocketService {

    private final CacheManager cacheManager;

    @Override
    public IPage<RentalSocket> selectJoinPage(Page page, RentalSocket pararm) {
        IPage<RentalSocket> pageList = baseMapper.selectJoinPage(page, pararm);
        if(  ObjectUtil.isNotEmpty(pageList) && ObjectUtil.isNotEmpty(pageList.getRecords()) ){
            pageList.getRecords().stream().forEach(item->{
                //TODO 后续优化部门缓存
//                Cache deprtCache =  cacheManager.getCache(CacheConstant.SYS_DEPARTS_CACHE);
//                if(ObjectUtil.isNotEmpty(deprtCache)){
//                    SysDepartVO departVO = deprtCache.get(item.getSysOrgCode(), SysDepartVO.class);
//                    if(ObjectUtil.isNotEmpty(departVO)){
//                        item.setSysOrgName(departVO.getDepartName());
//                    }
//                }
            });
        }
        return pageList;
    }
}
